home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / harderr.zip / NOWAY.ASM < prev    next >
Assembly Source File  |  1991-07-26  |  7KB  |  179 lines

  1. ; Program Name    : noway.asm
  2. ; Author          : bill buckels
  3. ; Date            : July 26, 1991
  4. ; Function        : tsr program to disable CONTROL C and CONTROL BREAK
  5.  
  6. kb_data       equ 60h                       ;keyboard data port
  7. kb_ctrl       equ 61h                       ;keyboard control port
  8. eoi           equ 20h                       ;8259 end-of-interrupt value
  9. int_ctrl_port equ 20h                       ;8259 PIC port
  10. c_key         equ 2Eh                       ;scan code for 'C' key
  11. ctrl_key      equ 4                         ;shift code for Ctrl key
  12. cr            equ  0dh                      ;carriage return
  13. lf            equ  0ah                      ;line feed
  14.  
  15. CODE          SEGMENT PARA PUBLIC 'CODE'
  16.               ASSUME CS:CODE
  17.               ORG 100h
  18.  
  19. BEGIN:        jmp INITIALIZE                ;jump to initialization code
  20.  
  21.  
  22. old_int_9h         label dword              ;old keyboard interrupt vector
  23. old_keyboard_int   dw 2 dup (?)
  24.  
  25. ;-------------------------------------------------------
  26. ;NO_CTRL_C resident mainline and
  27. ;Front-end routine for the keyboard interrupt handler.
  28. ;Execution is vectored here whenever an interrupt 9
  29. ;is generated by the keyboard.
  30. ;-------------------------------------------------------
  31.  
  32.  
  33. NO_CTRL_C     PROC NEAR
  34.               sti                           ;enable interrupts
  35.               push ax                       ;save registers
  36.               push bx
  37.               push cx
  38.               push dx
  39.               push si
  40.               push di
  41.               push ds
  42.               push es
  43.               in al,kb_data                 ;get scan code from keyboard
  44.               cmp al,c_key                  ;was the 'C' key pressed?
  45.               je  HOT_C                     ;yes...
  46.  
  47.               jne EXIT                      ;no, then exit to normal routine
  48. HOT_C:
  49.               mov ah,2                      ;get state of shift keys
  50.               int 16h
  51.               test al,ctrl_key              ;is the CTRL key depressed?
  52.               jne IGNORE                    ;yes, then continue
  53.  
  54. ;Exit is achieved thru here when execution is to be transferred
  55. ;to the normal
  56. ;BIOS keyboard interrupt handling routine.
  57.  
  58. EXIT:         pop es                        ;restore registers
  59.               pop ds
  60.               pop di
  61.               pop si
  62.               pop dx
  63.               pop cx
  64.               pop bx
  65.               pop ax
  66.               jmp old_int_9h                ;goto BIOS keyboard routine
  67.  
  68.  
  69. ;The key combination CTRL-C was just pressed.
  70. ;Reset the keyboard and issue an
  71. ;EOI to the 8259 PIC to enable hardware interrupts.
  72.  
  73. IGNORE:       call kb_reset               ;reset keyboard, end 8259 int
  74.               pop es                      ;restore register values for exit
  75.               pop ds
  76.               pop di
  77.               pop si
  78.               pop dx
  79.               pop cx
  80.               pop bx
  81.               pop ax
  82.               iret                          ;return to interrupted program
  83.  
  84. NO_CTRL_C     ENDP
  85.  
  86. ;-------------------------------------------------------------------
  87. ;KB_RESET resets the keyboard and issues an EOI (end of interrupt)
  88. ;to the 8259 PIC.
  89. ;-------------------------------------------------------------------
  90. kb_reset      PROC NEAR
  91.               in al,kb_ctrl                 ;get current control port value
  92.               mov ah,al                     ;save it in AH
  93.               or al,80h                     ;set bit 7
  94.               out kb_ctrl,al                ;send reset value
  95.               mov al,ah                     ;get original value
  96.               out kb_ctrl,al                ;send it out to enable keyboard
  97.               cli                           ;suspend interrupts
  98.               mov al,eoi                    ;get EOI value
  99.               out int_ctrl_port,al          ;send EOI to 8259
  100.               sti                           ;enable interrupts
  101.               ret
  102. kb_reset      ENDP
  103.  
  104.  
  105. ;-------------------------------------------------------
  106. ;routine for the CTRL-BREAK interrupt handler.
  107. ;Execution is vectored here whenever an interrupt 1Bh
  108. ;is generated.
  109. ;-------------------------------------------------------
  110.  
  111. NO_BREAK      PROC NEAR
  112.               sti                           ;enable interrupts
  113.               iret                          ;return to interrupted program
  114. NO_BREAK      ENDP
  115.  
  116. ;------------------------------------------------------------
  117. ;         RESIDENT PORTION ENDS *** TRANSIENT PORTION STARTS
  118. ;------------------------------------------------------------
  119.  
  120. ;------------------------------------------------------------
  121. ;initialization message
  122. ;------------------------------------------------------------
  123. CREDIT$      db 'NOWAY(C) by Bill Buckels 1991',cr,lf
  124.              db 'CTRL BREAK and CTRL C are now disabled',cr,lf,'$'
  125.  
  126. ;------------------------------------------------------------
  127. ;LIST$ writes a string to stdout
  128. ;------------------------------------------------------------
  129. LIST$ PROC NEAR
  130.       push ax
  131.       mov ah,9h ; call dos function 9H
  132.       int 21h
  133.       pop ax
  134.       ret
  135. LIST$ ENDP
  136.  
  137. ;----------------------------------------------------------------
  138. ;INITIALIZE performs tasks to set the stage for the resident part
  139. ;of the program.
  140. ;-----------------------------------------------------------------
  141. INITIALIZE    PROC NEAR
  142.  
  143. ;let them know who we are
  144.  
  145.               lea dx, CREDIT$
  146.               call LIST$
  147.  
  148. ;Now save the old interrupt 9 vector and replace it
  149. ;with one pointing to the
  150. ;code that we will leave behind in memory.
  151.  
  152.               mov ah,35h                    ;get current interrupt 9 vector
  153.               mov al,9
  154.               int 21h
  155.               mov old_keyboard_int,bx       ;save vector offset
  156.               mov old_keyboard_int[2],es    ;save vector segment
  157.               mov ah,25h                    ;set new vector
  158.               mov al,9
  159.               lea dx,NO_CTRL_C              ;point it to new handler
  160.               int 21h
  161.  
  162. ;Next point the interrupt 1B vector to a null function
  163. ;that we will leave behind in memory.
  164.  
  165.               mov ah,25h                        ;set new vector
  166.               mov al,1bh
  167.               lea dx,NO_BREAK                   ;point it to new handler
  168.               int 21h
  169.  
  170. ;Exit thru INT 27h and reserve enough room
  171. ;the offset of CREDIT$ is a marker to end of resident code
  172.  
  173.               mov dx,offset CREDIT$         ;reserve space for code
  174.               int 27h                       ;terminate-but-stay-resident
  175. INITIALIZE    ENDP
  176. ;
  177. CODE          ENDS
  178.               END BEGIN
  179.